import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class debug {
    private static ArrayList<String> tokens;

    public static void main(String[] args) throws IOException {
        File token_file = new File(args[0]);
        File output_file = new File(args[1]);
        Scanner in = new Scanner(token_file);
        String str = in.nextLine();
        in.close();
        str = str.substring(1, str.length() - 1);
//        System.out.println(str);
        String[] strings = str.split(", ");
        tokens = new ArrayList<>(Arrays.asList(strings));
        synAnalyse syn = new synAnalyse(tokens);//语法分析器
        AST tree = syn.build_AST();//生成语法树
        FileWriter out_write = new FileWriter(output_file);
        irGenerator generator = new irGenerator(out_write);//中间代码生成器
        generator.generate(tree);//遍历语法树,生成中间代码
        out_write.close();//关闭输出中间代码文件
    }
}
